### Needed packages
library(dplyr)
library(tidyr)
library(ggplot2)
library(ggmap)
library(scatterpie)
### Needed variables
# Make a nice color pallete and legend order for all plots
## health status
my_cols=c("darkgreen",
"darkred",
"orangered1",
"cadetblue",
"tan",
"beige",
# "burlywood4",
"coral",
"aquamarine3",
"gray70",
"black")
desired_order=c("healthy",
"ozone",
"ozone_and_other",
"others_combined",
"drougth",
"fungi",
# "insect",
"worm",
"acid_rain",
"other",
"dead")
spanish_labels=c("Sano",
"Ozono",
"Ozono y otros",
"Otros combinados no-ozono",
"SequÃa",
"Hongos",
# "Insectos",
"Gusano de seda",
"Lluvia acida",
"Otro",
"Muerto")
## Damage percentage
my_cols2<-c("gold2", "chocolate1", "orangered", "red4", "darkorchid4")
desired_order_percentage<-c("less than 10%", "10 to 40%", "40 to 50%", "50 to 70%", "more than 70%")
Este reporte explora los resultados del monitoreo participativo del estado de salud de árboles de oyamel en el Parque Nacional Desierto de los Leones y sus zonas de influencia en Bienes Comunales Santa Rosa Xochiac.
Los datos corresponden al resultado del muestreo participativo realizado por 12 brigadistas de Bienes Comunales Santa Rosa Xochiac, utilizando kobo-conabio como parte del proyecto 308488 Monitoreo y manejo para la conservación de bosques aledaños a la CDMX afectados por contaminación atmosférica de la convocatoria FORDECYT 2019-5.
Los datos del muestreo corresponden a los datos colectados con kobo y limpiados previamente con el script 1_preprocesamiento_datos_kobo.Rmd.
# load data
muestreo_tidy<-read.delim("../data/kobo/muestreo_dic2020_tidy.txt", header = TRUE)
parcelas_tidy<-read.delim("../data/kobo/parcelas_dic2020_tidy.txt", header = TRUE)
# pivot long parcelas data to have health data as a single variable
parcelas_long<-pivot_longer(parcelas_tidy,
cols = healthy:worm,
names_to = "tree_health_simplified",
values_to = "n_trees")
Los datos analizados aquà corresponden sólo a los árboles que fueron aprovados durante la validación revisando manualmente las fotografÃas en kobotoolbox. Del total de 1771 árboles muestreados, 1718 fueron aprovados en la validación.
muestreo_tidy<- filter(muestreo_tidy, X_validation_status=="validation_status_approved")
La siguiente figura muestra el total de árboles muestreados en cada parcela de 10x10 m, y cuántos de estos están bajo alguna categorÃa de daño:
p <- ggplot(parcelas_long, aes(x=plot, y=n_trees, fill=tree_health_simplified)) +
geom_bar(stat="identity") +
scale_fill_manual(values= my_cols, breaks = desired_order,
labels= spanish_labels,
name= "Estado de salud")
p + theme_bw() +
ggtitle("Estado de salud de los árboles por parcela") +
theme(plot.title = element_text(lineheight=1.1, face="bold")) +
labs(x="Parcelas", y= "número de árboles") +
theme(text = element_text(size = 20))
Esta es la distribución de las 48 parcelas:
# code adapted from https://rgraphgallery.blogspot.com/2013/04/rg-plot-pie-over-google-map.html
## configure google api
# You first need to register your api key in https://cloud.google.com/maps-platform/#get-started and follow instructions. The geocoding API is a free service, but you nevertheless need to associate a credit card with the account. Please note that the Google Maps API is not a free service. There is a free allowance of 40,000 calls to the geocoding API per month, and beyond that calls are $0.005 each.
# after you obtain your api, save it in /scripts/api_key.api (not shown in this repo por obvious reasons).
# if you get the following error when running get_map():
#"Error in aperm.default(map, c(2, 1, 3)) :
# invalid first argument, must be an array "
# check this troubleshooting: https://rgraphgallery.blogspot.com/2013/04/rg-plot-pie-over-google-map.html
## load and register api
api <- readLines("api_key.api")
register_google(key = api)
## plot map
# get map
sat_map = get_map(location = c(lon = -99.3060, lat = 19.2909), zoom = 14, maptype = 'satellite', source = "google")
# plot sampled plots
p_satmap <- ggmap(sat_map)
p_satmap + geom_point(data=parcelas_tidy,
aes(x=X_coordinates_longitude,
y=X_coordinates_latitude),
color="red") +
geom_text(data=parcelas_tidy,
aes(x=X_coordinates_longitude,
y=X_coordinates_latitude,
label=plot),
color="white",
# check_overlap = TRUE,
hjust = 0, vjust=1, nudge_x = 0.0005,
size= 5) +
theme(text = element_text(size = 30))